package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	dial, err := redis.Dial("tcp", "localhost:6379")
	if err != nil {
		fmt.Println("Redis connect is error, reason:", err)
		return
	}
	defer dial.Close()
	// 设置获取字符串
	_, err = dial.Do("set", "username", "123")
	if err != nil {
		return
	}
	// 获取字符串
	res, err := redis.Int(dial.Do("get", "username"))
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res)

}

